-
Notifications
You must be signed in to change notification settings - Fork 391
fix(clerk-js): Ensure input feedback messages are mapped to the input #6914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(clerk-js): Ensure input feedback messages are mapped to the input #6914
Conversation
🦋 Changeset detectedLatest commit: acc57ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughCentralizes feedback ID generation and aria-live handling: introduces Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Input
participant Hook as useFormField
participant FormFB as FormFeedback
participant Text as InfoText
User->>Input: interact / type
Input->>Hook: request props (id, state, debounced feedback)
Hook-->>Input: { fieldId, feedbackType, feedbackMessageId, ... }
alt set aria-describedby
Input->>Input: aria-describedby = combine(existing, feedbackMessageId?)
end
Input->>FormFB: render feedback (type, message)
rect rgba(219,234,254,0.35)
FormFB->>FormFB: generate id:
note right of FormFB #dbeafe: if type==='error' -> "error-${id}"\nelse -> "${id}-${type}-feedback"
FormFB->>Text: render with id and aria-live ('polite' when entering, 'off' otherwise)
end
Text-->>User: assistive tech receives updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1).changeset/**📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx (1)
136-153
: Minor: Type safety concern with sanitizeInputProps.The destructuring correctly includes
feedbackMessageId
and the comment update is appropriate. However, the pattern of using@ts-ignore
for dynamic property access (line 151) bypasses type checking.Consider using a type-safe approach:
keep?.forEach(key => { - /** - * Ignore error for the index type as we have defined it explicitly above - */ - // @ts-ignore - Dynamic property access for form field props - inputProps[key] = obj[key]; + if (key in obj) { + (inputProps as any)[key] = obj[key]; + } });This maintains type safety for the common case while explicitly handling dynamic access for the
keep
parameter.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (8)
packages/clerk-js/src/ui/elements/FormControl.tsx
(4 hunks)packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
(4 hunks)packages/clerk-js/src/ui/primitives/FormErrorText.tsx
(0 hunks)packages/clerk-js/src/ui/primitives/FormInfoText.tsx
(0 hunks)packages/clerk-js/src/ui/primitives/FormSuccessText.tsx
(0 hunks)packages/clerk-js/src/ui/primitives/FormWarningText.tsx
(0 hunks)packages/clerk-js/src/ui/primitives/Input.tsx
(2 hunks)packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
(6 hunks)
💤 Files with no reviewable changes (4)
- packages/clerk-js/src/ui/primitives/FormInfoText.tsx
- packages/clerk-js/src/ui/primitives/FormSuccessText.tsx
- packages/clerk-js/src/ui/primitives/FormWarningText.tsx
- packages/clerk-js/src/ui/primitives/FormErrorText.tsx
🧰 Additional context used
📓 Path-based instructions (13)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Visual regression testing should be performed for UI components.
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.test.{jsx,tsx}
: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/primitives/Input.tsx (1)
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx (1)
sanitizeInputProps
(119-156)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (10)
packages/clerk-js/src/ui/elements/FormControl.tsx (3)
43-43
: LGTM: Dependency array correctly updated.The addition of
appearanceAnimations
to the dependency array is correct since it's used in the callback body (line 26).
146-149
: LGTM: Clear ID generation strategy for all feedback types.The unique ID generation for all feedback types (not just errors) enables proper
aria-describedby
associations. The distinction between error IDs (errorMessageId
) and other feedback IDs (${id}-${type}-feedback
) is well-documented and maintains backward compatibility.
184-184
: Excellent: Centralized aria-live handling improves accessibility.The conditional
aria-live
attributes ('polite' whenshouldEnter
is true, 'off' otherwise) ensure that only the currently visible feedback message is announced to screen readers. This prevents duplicate announcements during feedback transitions and properly coordinates with thearia-describedby
associations established in the input components.Also applies to: 196-196
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx (2)
14-14
: LGTM: feedbackMessageId properly integrated into form field context.The
feedbackMessageId
concept is correctly:
- Added to the type definition
- Computed based on
debounced.feedback
anddebounced.feedbackType
- Propagated through context value and memoization dependencies
This enables consistent ID generation across all feedback types for proper
aria-describedby
associations.Also applies to: 53-56, 65-65, 82-82
53-56
: No change needed for dual aria-describedby IDs
The dual ID strategy is intentional—Input.tsx joins botherrorMessageId
andfeedbackMessageId
for error cases (as verified by PlainInput.test.tsx), while FormControl/FormFeedback still render onlyerrorMessageId
for errors.packages/clerk-js/src/ui/primitives/Input.tsx (1)
107-107
: LGTM: aria-describedby properly composes multiple feedback IDs.The implementation correctly:
- Combines
errorMessageId
andfeedbackMessageId
when both are present- Filters out falsy values to avoid empty strings in the attribute
- Joins IDs with a space as required by the ARIA specification
- Falls back to
undefined
when no IDs are present, keeping the attribute cleanThis ensures screen readers can access all relevant feedback messages associated with the input.
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (4)
24-26
: Excellent: Comprehensive test setup and error feedback verification.The test enhancements properly verify:
- Addition of success/warning/info feedback controls alongside error
- The
container
reference for DOM queries to verify element IDs- The updated error behavior including both
error-firstname
andfirstname-error-feedback
inaria-describedby
- The presence and content of the error element with the correct ID
This confirms the dual ID strategy for errors is intentional and properly implemented.
Also applies to: 138-153
170-192
: LGTM: Success feedback test validates new aria-describedby behavior.The test correctly verifies:
- Success feedback message rendering
aria-invalid
set to 'false' for non-error feedbackaria-describedby
contains only the success feedback ID (no dual ID for non-error cases)- The success element exists with the correct ID and content
This confirms the implementation properly distinguishes between error and non-error feedback types.
194-225
: LGTM: Transition test confirms proper state management.The test validates critical behavior when switching between feedback types:
- Error → Success transition properly updates
aria-describedby
from dual IDs to single IDaria-invalid
correctly toggles from 'true' to 'false'- The success element replaces the error element in the DOM
This ensures the accessibility attributes remain consistent during feedback type changes.
227-258
: Excellent: aria-live test confirms centralized live region management.The test validates the key accessibility improvement introduced in this PR:
- Error feedback has
aria-live="polite"
when visible- Success feedback has
aria-live="polite"
when visible- Only the currently visible feedback has
aria-live="polite"
(previous one switches to 'off')- At least one live region exists with 'polite' setting
This confirms the FormFeedback component properly manages live regions to prevent duplicate announcements while ensuring current feedback is announced to screen readers.
// @ts-expect-error Typescript is complaining that `errorMessageId` and `feedbackMessageId` do not exist. We are clearly passing them from above. | ||
const { errorMessageId, feedbackMessageId, ignorePasswordManager, feedbackType, ...fieldControlProps } = | ||
sanitizeInputProps(fieldControl, ['errorMessageId', 'feedbackMessageId', 'ignorePasswordManager', 'feedbackType']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Fix type definitions to eliminate ts-expect-error.
The ts-expect-error
comment indicates that errorMessageId
and feedbackMessageId
are not properly typed in the return value of sanitizeInputProps
. This bypasses type safety and could mask future type errors.
Update the return type of sanitizeInputProps
in useFormField.tsx
to explicitly include these properties when they're in the keep
array:
export const sanitizeInputProps = <K extends keyof ReturnType<typeof useFormField>>(
obj: ReturnType<typeof useFormField>,
keep?: K[],
): Omit<ReturnType<typeof useFormField>,
'radioOptions' | 'validatePassword' | 'hasPassedComplexity' | 'isFocused' |
'feedback' | 'feedbackType' | 'setHasPassedComplexity' | 'setWarning' |
'setSuccess' | 'setError' | 'setInfo' | 'errorMessageId' | 'feedbackMessageId' |
'fieldId' | 'label' | 'clearFeedback' | 'infoText' | 'debouncedFeedback' |
'ignorePasswordManager' | 'transformer'
> & Pick<ReturnType<typeof useFormField>, K extends keyof ReturnType<typeof useFormField> ? K : never> => {
// implementation
}
Alternatively, consider using a simpler approach with proper type assertions where the dynamic behavior is actually needed.
// We can verify the currently visible element has aria-live="polite" | ||
const allAriaLivePolite = container.querySelectorAll('[aria-live="polite"]'); | ||
// At least the success message should have aria-live="polite" | ||
expect(allAriaLivePolite.length).toBeGreaterThanOrEqual(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that me strictly equal to one ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, good catch! 651f11b
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
…d-is-correctly-attached-to-the-aria-live
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/clerk-js/src/ui/elements/FormControl.tsx (1)
137-147
: Prevent duplicate feedback IDs during cross-fade.
getElementProps
assigns the same id to both slots even whenshouldEnter
isfalse
. When a new message of the same type (e.g., another error) arrives, both rendered nodes momentarily share that id—one hidden, one live. Becausearia-describedby
resolves to the first matching id, assistive tech can end up reading the stale, hidden message. Please only apply the id when we actually render the active message (and skip it entirely ifid
is undefined) so the live region stays unique and screen readers follow the current feedback.Also applies to: 172-195
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (7)
packages/clerk-js/src/ui/elements/FieldControl.tsx
(1 hunks)packages/clerk-js/src/ui/elements/FormControl.tsx
(5 hunks)packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
(4 hunks)packages/clerk-js/src/ui/primitives/FormErrorText.tsx
(1 hunks)packages/clerk-js/src/ui/primitives/FormInfoText.tsx
(1 hunks)packages/clerk-js/src/ui/primitives/Input.tsx
(2 hunks)packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/clerk-js/src/ui/primitives/FormInfoText.tsx
🧰 Additional context used
📓 Path-based instructions (13)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/elements/FormControl.tsx
packages/clerk-js/src/ui/elements/FieldControl.tsx
packages/clerk-js/src/ui/primitives/Input.tsx
packages/clerk-js/src/ui/primitives/FormErrorText.tsx
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Visual regression testing should be performed for UI components.
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.test.{jsx,tsx}
: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/primitives/Input.tsx (1)
packages/clerk-js/src/ui/primitives/hooks/useFormField.tsx (1)
sanitizeInputProps
(120-156)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
- GitHub Check: Integration Tests (handshake:staging, chrome)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Integration Tests (machine, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 14)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (handshake, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (quickstart, chrome)
- GitHub Check: Integration Tests (tanstack-react-router, chrome)
- GitHub Check: Integration Tests (expo-web, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (elements, chrome)
- GitHub Check: Integration Tests (sessions:staging, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: Static analysis
- GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
- GitHub Check: Unit Tests (22, **)
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
Outdated
Show resolved
Hide resolved
…d-is-correctly-attached-to-the-aria-live
Description
aria-describedby
to the password input that maps to the currently rendered feedback messagearia-live='polite'
fixes USER-3619
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
New Features
Bug Fixes
Tests